/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package uit.qlks.controller.loaidichvu;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.sql.rowset.WebRowSet;
import uit.ejb.bo.loaidichvu.LoaiDichVuBORemote;
import uit.ejb.bo.loaidichvu.LoaiDichVuBORemoteHome;
import uit.ejb.dto.LoaiDichVuDTO;

/**
 *
 * @author Restart
 */
public class LoaiDichVuController {

    private static Context ctx;
    private static LoaiDichVuBORemoteHome phome;
    private static LoaiDichVuBORemote dv;
    public LoaiDichVuController(){

    }

    public static void Register(){
        try{
            ctx = new InitialContext();
            Object obj = ctx.lookup("ejb/LoaiDichVuBO");
            phome = (LoaiDichVuBORemoteHome) PortableRemoteObject.narrow(obj, LoaiDichVuBORemoteHome.class);
            dv=phome.create();
        }
        catch(Exception e){
        }
    }

    public static boolean loaiDichVu_Insert(LoaiDichVuDTO loaidichvu) {
        try{
            Register();
            return dv.loaiDichVu_Insert(loaidichvu);
        }catch(Exception e){
            return false;
        }
    }

    public static boolean loaiDichVu_Update(LoaiDichVuDTO loaidichvu) {
        try{
            Register();
            return dv.loaiDichVu_Update(loaidichvu);
        }catch(Exception e){
            return false;
        }
    }

    public static boolean loaiDichVu_Delete(String id) {
        try{
            Register();
            return dv.loaiDichVu_Delete(id);
        }catch(Exception e){
            return false;
        }
    }

    public static WebRowSet loaiDichVu_GetByAll() {
        try{
            Register();
            return dv.loaiDichVu_GetByAll();
        }catch(Exception e){
            return null;
        }
    }

    public static WebRowSet loaiDichVu_GetById(String id) {
        try{
            Register();
            return dv.loaiDichVu_GetById(id);
        }catch(Exception e){
            return null;
        }
    }
}
